brushless15 2.2.0
Loading...
Searching...
No Matches
brushless15


Brushless 15 Click

Brushless 15 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : Oct 2021.
  • Type : PWM type

Software Support

Example Description

This example demonstrates the use of the Brushless 15 Click board by driving the motor in both directions at different speeds.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Brushless15

Example Key Functions

Application Init

Initializes the driver and performs the Click default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
brushless15_cfg_t brushless15_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
brushless15_cfg_setup( &brushless15_cfg );
BRUSHLESS15_MAP_MIKROBUS( brushless15_cfg, MIKROBUS_1 );
if ( PWM_ERROR == brushless15_init( &brushless15, &brushless15_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( BRUSHLESS15_ERROR == brushless15_default_cfg ( &brushless15 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
@ BRUSHLESS15_ERROR
Definition brushless15.h:159
#define BRUSHLESS15_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition brushless15.h:98
void application_init(void)
Definition main.c:36

Application Task

Controls the motor speed by changing the PWM duty cycle once per second. The duty cycle ranges from 20% to 80%. At the minimal speed, the motor switches direction. Each step will be logged on the USB UART where you can track the program flow.

void application_task ( void )
{
static int8_t duty_cnt = 2;
static int8_t duty_inc = 1;
float duty = duty_cnt / 10.0;
brushless15_set_duty_cycle ( &brushless15, duty );
log_printf( &logger, "> Duty: %d%%\r\n", ( uint16_t )( duty_cnt * 10 ) );
Delay_ms ( 1000 );
duty_cnt += duty_inc;
if ( 8 == duty_cnt )
{
duty_inc = -1;
}
else if ( 1 == duty_cnt )
{
duty_inc = 1;
duty_cnt = 2;
log_printf( &logger, " Switch direction\r\n\n" );
brushless15_switch_direction ( &brushless15 );
}
}
void application_task(void)
Definition main.c:71

Note

The maximal PWM Clock frequency for this Click board is 1 kHz. So, depending on the selected setup the user will need to lower the MCU's main clock frequency in the setup in order to get the PWM clock frequency down to 1 kHz.

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.